package org.kabanyo.components.supportClasses {
	import org.kabanyo.components.IColorIndicator;

	public class ColorIndicator implements IColorIndicator {
		private var _color:uint;

		[Bindable]
		/**
		 * Color for indicated value between minimum and maximum.
		 */
		public function get color():uint {
			return _color;
		}

		/**
		 * @private
		 */
		public function set color(value:uint):void {
			_color = value;
		}

		private var _minValue:Number;

		[Bindable]
		/**
		 * Minimum value.
		 */
		public function get minValue():Number {
			return _minValue;
		}

		/**
		 * @private
		 */
		public function set minValue(value:Number):void {
			_minValue = value;
			_isValid = validateValues();
		}

		private var _maxValue:Number;

		/**
		 * Maximum value.
		 */
		public function get maxValue():Number {
			return _maxValue;
		}

		/**
		 * @private
		 */
		public function set maxValue(value:Number):void {
			_maxValue = value;
			_isValid = validateValues();
		}

		private var _isValid:Boolean = false;

		[Bindable]
		/**
		 * True if maximum and minimum value is correct.
		 */
		public function get isValid():Boolean {
			return _isValid;
		}

		/**
		 * @private
		 */
		public function set isValid(value:Boolean):void {
			_isValid = value;
		}

		/**
		 * Constructor
		 *
		 */
		public function ColorIndicator() {
			//NOOP
		}

		private function validateValues():Boolean {
			if (minValue < maxValue) {
				return true;
			} else {
				return false;
			}
		}
	}
}
